
import java.util.*;
// 注意类名必须为 Main, 不要有任何 package xxx 信息
public class Main
{
    public static void main(String[] args)
    {
        Scanner in = new Scanner(System.in);
        int n = in.nextInt(), m = in.nextInt();
        TreeSet<Integer> set = new TreeSet<>();
        int x;
        while(n-- != 0){
            x = in.nextInt(); set.add(x);
        }
        while(m-- != 0) {
            x = in.nextInt();
            set.add(x);
        }
        for(int a : set) {
            System.out.print(a + " ");
        }
    }
}

